<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('common', 'Notes') . ' - ' . Yii::$app->params['site_name'];
$this->params['breadcrumbs'][] = Yii::t('common', 'Notes');
?>
<div class="catelog-index row">
    <div class="col-md-8 br10 white">
        <h1 class="sky"><i class="iconfont">&#xe606;</i><?= Yii::t('common', 'Notes') ?></h1>
        <hr>
        <?php foreach ($model as $value): ?>
            <div class="row pb">
                <div class="col-md-4">
                    <?php
                    if (!empty($value['img'])) {
                        echo '<span><a href="'.Url::to('/note/' . $value['id']).'" title="' . $value['title'] . '"><img src="'.Yii::$app->params['img_domain'].$value['img'].'" alt="'.$value['title'].'" class="list-img"></a></span>';
                    } else {
                        echo '<span><img src="'.Yii::$app->params['frontend_domain'].'/img/default.jpg" title="'.$value['title'].'"  class="list-img" /></span>';
                    }                        
                    ?>
                </div>
                <div class="col-md-8">
                    <h3 class="list-h3"><small>
                            <span><?= Html::a($value['c']['title'], Url::to('/catelog/' . $value['c']['slug']), ['title' => $value['c']['title'], 'class' => 'btn btn-success', 'role' => 'button']); ?></span>&nbsp;&nbsp;
                            <span><?= Html::a($value['title'], Url::to('/note/' . $value['id']), ['title' => $value['title'] . '笔记']); ?></span>
                        </small></h3>
                    <p>
                        <span class="attr" title="作者"><i class="iconfont">&#xe630;</i><?= $value['author']; ?></span>
                        <span class="attr" title="日期"><i class="iconfont">&#xe6f0;</i><?= date('Y-m-d H:i:s', $value['updated_at']); ?></span>&nbsp;&nbsp;&nbsp;&nbsp;
                        <span class="attr" title="浏览量"><i class="iconfont">&#xe6a4;</i><?= $value['view']; ?></span>&nbsp;&nbsp;&nbsp;&nbsp;
                        <span title="标签"><i class="iconfont">&#xe60d;</i><?= Html::a($value['tag'], Url::to('/topic/' . $value['tag']), ['title' => $value['tag']]); ?></span>
                    </p>
                    <div class="description"><?= $value['description']; ?></div>
                </div>
            </div>
        <?php endforeach; ?>
        <?=LinkPager::widget(['pagination' => $pagination]);?>
    </div>
    <div class="col-md-4 br10 white">
        <div class="row widget">
            <div class="col-md-12">
                <h2 class="widget_title"><small><i class="iconfont">&#xe647;</i>热门推荐</small></h2>
                <hr>
                <?php
                foreach ($hot as $value) {
                    echo '<p class="article"><i class="iconfont fs20">&#xe89d;</i>';
                    echo Html::a($value['title'], Url::to('/topic/' . $value['id']));
                    echo '</p>';
                }
                ?>
            </div>
        </div>
        <div class="row widget">
            <div class="col-md-12">
                <h2 class="widget_title"><small><i class="iconfont">&#xe60d;</i>标签聚合</small></h2>
                <hr>
                <?php
                foreach ($tag as $value) {
                    echo '<span class="widget-tag">';
                    echo Html::a($value['tag'], Url::to('/topic/' . $value['tag']), ['title' => $value['tag'], 'class' => 'btn btn-default', 'role' => 'button']);
                    echo '</span>';
                }
                ?>
            </div>
        </div>        
    </div>
</div>
